
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/physics/mechanics/sympy_mechanics_for_autolev_users.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:39 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>SymPy Mechanics for Autolev Users &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../../_static/sympy-notailtext-favicon.ico"/>
    <link href="sympy_mechanics_for_autolev_users.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Masses, Inertias &amp; Particles, RigidBodys (Docstrings)" href="api/part_bod.html" />
    <link rel="prev" title="Autolev Parser" href="autolev_parser.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api/part_bod.html" title="Masses, Inertias &amp; Particles, RigidBodys (Docstrings)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="autolev_parser.html" title="Autolev Parser"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" accesskey="U">Classical Mechanics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">SymPy Mechanics for Autolev Users</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="sympy-mechanics-for-autolev-users">
<span id="id1"></span><h1>SymPy Mechanics for Autolev Users<a class="headerlink" href="#sympy-mechanics-for-autolev-users" title="Permalink to this headline">¶</a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Autolev (now superseded by MotionGenesis) is a domain specific programming
language which is used for symbolic multibody dynamics. The SymPy mechanics
module now has enough power and functionality to be a fully featured symbolic
dynamics module. The PyDy package extends the SymPy output to the numerical
domain for simulation, analyses and visualization. Autolev and SymPy Mechanics have
a lot in common but there are also many differences between them.
This page shall expand upon their differences. It is meant to be a go-to
reference for Autolev users who want to transition to SymPy Mechanics.</p>
<p>It would be nice to have a basic understanding of SymPy and SymPy Mechanics before
going over this page.
If you are completely new to Python, you can check out the official
<a class="reference external" href="https://docs.python.org/3/tutorial/">Python Tutorial</a>.
Check out the <a class="reference internal" href="../../../index.html#documentation"><span class="std std-ref">SymPy Documentation</span></a>, especially
the tutorial to get a feel for SymPy.
For an introduction to Multibody dynamics in Python, <a class="reference external" href="https://www.youtube.com/watch?v=mdo2NYtA-xY&amp;t=6950s">this</a>
lecture is very helpful.</p>
<p>You might also find the <a class="reference internal" href="autolev_parser.html#autolev-parser"><span class="std std-ref">Autolev Parser</span></a> which is
a part of SymPy to be helpful.</p>
</section>
<section id="some-key-differences">
<h2>Some Key Differences<a class="headerlink" href="#some-key-differences" title="Permalink to this headline">¶</a></h2>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p><strong>Autolev</strong></p></th>
<th class="head"><p><strong>SymPy Mechanics</strong></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><div class="line-block">
<div class="line">Autolev is a domain specific
programming language designed to
perform multibody dynamics. Since
it is a language of its own, it
has a very rigid language
specification. It predefines,
assumes and computes
many things based on the
input code. Its code is a lot
cleaner and concise as a result of
this.</div>
</div>
</td>
<td><div class="line-block">
<div class="line">SymPy is a library written in the
general purpose language Python.
Although Autolev’s code is more
compact, SymPy (by virtue of being
an add on to Python) is more
flexible. The users have more
control over what they can do. For
example, one can create a class in
their code for let’s say a type of
rigibodies with common
properties.
The wide array of scientific
Python libraries available is also
a big plus.</div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line">Autolev generates Matlab, C, or
Fortran code from a small set of
symbolic mathematics.</div>
</div>
</td>
<td><div class="line-block">
<div class="line">SymPy generates numerical Python,
C or Octave/Matlab code from a
large set of symbolic mathematics
created with SymPy. It also builds
on the popular scientific Python
stack such as NumPy, SciPy,
IPython, matplotlib, Cython and
Theano.</div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="line-block">
<div class="line">Autolev uses 1 (one) based
indexing. The initial element of
a sequence is found using a[1].</div>
</div>
</td>
<td><div class="line-block">
<div class="line">Python uses 0 (zero) based
indexing. The initial element of
a sequence is found using a[0].</div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line">Autolev is case insensitive.</div>
</div>
</td>
<td><div class="line-block">
<div class="line">SymPy code being Python code is
case sensitive.</div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="line-block">
<div class="line">One can define their own commands
in Autolev by making .R and .A
files which can be used in their
programs.</div>
</div>
</td>
<td><div class="line-block">
<div class="line">SymPy code is Python code, so one
can define functions in their
code. This is a lot more
convenient.</div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line">Autolev is proprietary.</div>
</div>
</td>
<td><div class="line-block">
<div class="line">SymPy is open source.</div>
</div>
</td>
</tr>
</tbody>
</table>
</section>
<section id="rough-autolev-sympy-equivalents">
<h2>Rough Autolev-SymPy Equivalents<a class="headerlink" href="#rough-autolev-sympy-equivalents" title="Permalink to this headline">¶</a></h2>
<p>The tables below give rough equivalents for some common Autolev
expressions. <strong>These are not exact equivalents</strong>, but rather should be
taken as hints to get you going in the right direction. For more detail
read the built-in documentation on <a class="reference internal" href="../vector/index.html#physics-vector"><span class="std std-ref">SymPy vectors</span></a>,
<a class="reference internal" href="index.html#classical-mechanics"><span class="std std-ref">SymPy mechanics</span></a> and
<a class="reference external" href="https://www.pydy.org/documentation.html">PyDy</a> .</p>
<p>In the tables below, it is assumed that you have executed the following
commands in Python:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sympy.physics.mechanics</span> <span class="k">as</span> <span class="nn">me</span>
<span class="kn">import</span> <span class="nn">sympy</span> <span class="k">as</span> <span class="nn">sm</span>
</pre></div>
</div>
<section id="mathematical-equivalents">
<h3>Mathematical Equivalents<a class="headerlink" href="#mathematical-equivalents" title="Permalink to this headline">¶</a></h3>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p><strong>Autolev</strong></p></th>
<th class="head"><p><strong>SymPy</strong></p></th>
<th class="head"><p><strong>Notes</strong></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span> <span class="pre">A,</span> <span class="pre">B</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">a,</span> <span class="pre">b</span> <span class="pre">=</span>
<span class="pre">sm.symbols(‘a</span>
 <span class="pre">b’,</span> <span class="pre">real=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line">Note that the names
of the symbols can be
different from the
names of the
variables they are
assigned to. We can
define <code class="docutils literal notranslate"><span class="pre">a,</span> <span class="pre">b</span> <span class="pre">=</span>
<span class="pre">symbols(‘b</span> <span class="pre">a’)</span></code> but
its good practice to
follow the
convention.</div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span> <span class="pre">C+</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">=</span> <span class="pre">sm.symbols(‘c’,</span>
<span class="pre">real=True,</span>
<span class="pre">nonnegative=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line">Refer to SymPy
<a class="reference internal" href="../../assumptions/index.html#assumptions-module"><span class="std std-ref">assumptions</span></a>
for more information.</div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span> <span class="pre">D-</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">d</span> <span class="pre">=</span> <span class="pre">sm.symbols(‘d’,</span>
<span class="pre">real=True,</span>
<span class="pre">nonpositive=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span> <span class="pre">K{4}</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">k1,</span> <span class="pre">k2,</span> <span class="pre">k3,</span> <span class="pre">k4</span> <span class="pre">=</span>
<span class="pre">sm.symbols('k1</span> <span class="pre">k2</span> <span class="pre">k3</span>
<span class="pre">k4',</span> <span class="pre">real=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span> <span class="pre">a{2:4}</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">a2,</span> <span class="pre">a3,</span> <span class="pre">a4</span> <span class="pre">=</span>
<span class="pre">sm.symbols('a2</span> <span class="pre">a3</span> <span class="pre">a4',</span>
<span class="pre">real=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Constants</span>
<span class="pre">b{1:2,</span> <span class="pre">1:2}</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">b11,</span> <span class="pre">b12,</span> <span class="pre">b21,</span> <span class="pre">b22</span> <span class="pre">=</span>
<span class="pre">sm.symbols('b11</span> <span class="pre">b12</span>
<span class="pre">b21</span> <span class="pre">b22',</span> <span class="pre">real=True)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Specified</span> <span class="pre">Phi</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">phi</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘phi</span>
<span class="pre">')</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Variables</span> <span class="pre">q,</span> <span class="pre">s</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">q,</span> <span class="pre">s</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(q,</span>
<span class="pre">s)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Variables</span> <span class="pre">x’’</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘x’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">xd</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘x’</span>
<span class="pre">,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">xd2</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘x’</span>
<span class="pre">,</span> <span class="pre">2)</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Variables</span> <span class="pre">y{2}’</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">y1</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘y1’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">y2</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘y2’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">y1d</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘y1’</span>
<span class="pre">,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">y2d</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘y2'</span>
<span class="pre">,</span> <span class="pre">1)</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">MotionVariables</span>
<span class="pre">u{2}</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">u1</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols(‘u1’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">u2</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols('u2'</span>
<span class="pre">)</span></code></p>
</td>
<td><p>SymPy doesn’t
differentiate between
variables,
motionvariables and
specifieds during
declaration. Instead,
it takes different
lists of these as
parameters in objects
like the KanesMethod.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Imaginary</span> <span class="pre">j</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">j</span> <span class="pre">=</span> <span class="pre">sm.I</span></code></p></td>
<td><p>I is a sympy object
which stands for the
imaginary unit. One
can define complex
numbers using it.</p>
<p><code class="docutils literal notranslate"><span class="pre">z</span> <span class="pre">=</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">I*y</span></code></p>
<p>where x, y and z are
symbols.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Tina</span> <span class="pre">=</span> <span class="pre">2*pi</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">s</span> <span class="pre">=</span> <span class="pre">u*t</span> <span class="pre">+</span> <span class="pre">a*t^2/2</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">tina</span> <span class="pre">=</span> <span class="pre">2*sm.pi</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">tina</span> <span class="pre">=</span>
<span class="pre">tina.evalf()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">t</span> <span class="pre">=</span>
<span class="pre">me.dynamicsymbols._t</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">s</span> <span class="pre">=</span> <span class="pre">u*t</span> <span class="pre">+</span> <span class="pre">a*t**2/2</span></code></p>
</td>
<td><p>Using <code class="docutils literal notranslate"><span class="pre">.evalf()</span></code>
will result in the
numeric value.</p></td>
</tr>
<tr class="row-odd"><td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">abs(x)^3</span> <span class="pre">+</span> <span class="pre">sin(x)^2</span>
<span class="pre">+</span> <span class="pre">acos(x)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">sm.abs(x)**3</span>
<span class="pre">+</span> <span class="pre">sm.sin(x)**2</span> <span class="pre">+</span>
<span class="pre">sm.acos(x)</span></code></div>
</div>
</td>
<td><div class="line-block">
<div class="line"><br /></div>
</div>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">E</span> <span class="pre">=</span> <span class="pre">(x+2*y)^2</span> <span class="pre">+</span>
<span class="pre">3*(7+x)*(x+y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Expand(E)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Factor(E,</span> <span class="pre">x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Coef(y,</span> <span class="pre">x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Replace(y,</span>
<span class="pre">sin(x)=3)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Exclude(E,x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Include(E,x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Arrange(E,2,y)</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">E</span> <span class="pre">=</span> <span class="pre">(x+2*y)**2</span> <span class="pre">+</span>
<span class="pre">3*(7+x)*(x+y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">sm.expand(E)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">sm.horner(E,</span>
<span class="pre">wrt=x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">y.coeff(x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">y.subs({sm.sin(x):</span>
<span class="pre">3})</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">e.collect(x).coeff(</span>
<span class="pre">x,</span> <span class="pre">0)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">e.collect(x).coeff(</span>
<span class="pre">x,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">e.collect(y)</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../../../tutorial/simplification.html#tutorial-simplify"><span class="std std-ref">simplification.</span></a></p>
<p>These SymPy functions
do not work in place.
They just return
expressions. If you
want to overwrite the
original expression
you would have to do
something like:</p>
<p><code class="docutils literal notranslate"><span class="pre">y</span> <span class="pre">=</span>
<span class="pre">y.subs({sm.sin(x):</span>
<span class="pre">3})</span></code></p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Dy</span> <span class="pre">=</span> <span class="pre">D(E,</span> <span class="pre">y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Dt</span> <span class="pre">=</span> <span class="pre">Dt(E)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Dt2</span> <span class="pre">=</span> <span class="pre">Dt(V,</span> <span class="pre">A)</span></code>
where V is a vector
and A is a frame</p>
<p><code class="docutils literal notranslate"><span class="pre">Dy2</span> <span class="pre">=</span> <span class="pre">D(V,</span> <span class="pre">y,</span> <span class="pre">A)</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">E.diff(y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">E.diff(</span>
<span class="pre">me.dynamicsymbols._t</span>
<span class="pre">)</span></code></p>
<p>Works if the
expression is made up
of dynamicsymbols.</p>
<p><code class="docutils literal notranslate"><span class="pre">dt2</span> <span class="pre">=</span> <span class="pre">v.dt(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">dy2</span> <span class="pre">=</span> <span class="pre">v.diff(y,</span> <span class="pre">A)</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../../../tutorial/calculus.html#calculus"><span class="std std-ref">calculus.</span></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">E</span> <span class="pre">=</span> <span class="pre">COS(X*Y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">TY</span> <span class="pre">=</span> <span class="pre">Taylor(E,</span>
<span class="pre">0:2,</span> <span class="pre">x=0,</span> <span class="pre">y=0)</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">e</span> <span class="pre">=</span> <span class="pre">sm.cos(x*y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">b</span> <span class="pre">=</span> <span class="pre">e.series(x,</span> <span class="pre">0,</span>
<span class="pre">2).removeO().series(y,</span>
<span class="pre">0,</span> <span class="pre">2).removeO()</span></code></p>
</td>
<td><p>For more information
refer to <a class="reference internal" href="../../series/series.html#series-expansions"><span class="std std-ref">series.</span></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">F</span> <span class="pre">=</span> <span class="pre">Evaluate(E,</span>
<span class="pre">x=a,</span> <span class="pre">y=2)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">E.subs([(x,</span> <span class="pre">a),</span> <span class="pre">(y,</span>
<span class="pre">2)])</span></code></p>
<p>To get floating point
numbers from numerical
expressions use
<code class="docutils literal notranslate"><span class="pre">.evalf()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">E.evalf((a</span> <span class="pre">+</span>
<span class="pre">sm.pi).subs({a:</span> <span class="pre">3}))</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">P</span> <span class="pre">=</span> <span class="pre">Polynomial([a,</span>
<span class="pre">b,</span> <span class="pre">c],</span> <span class="pre">x)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">p</span> <span class="pre">=</span>
<span class="pre">sm.Poly(sm.Matrix([a,</span>
<span class="pre">b,</span> <span class="pre">c]).reshape(1,</span> <span class="pre">3),</span>
<span class="pre">x)</span></code></p></td>
<td><p>For more information
refer to
<a class="reference internal" href="../../polys/reference.html#polys-reference"><span class="std std-ref">polys.</span></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Roots(Polynomial(</span>
<span class="pre">a*x^2</span> <span class="pre">+</span> <span class="pre">b*x</span> <span class="pre">+</span> <span class="pre">c,</span> <span class="pre">x,</span>
<span class="pre">2)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Roots([1;2;3])</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">sm.solve(</span>
<span class="pre">sm.Poly(a*x**2</span> <span class="pre">+</span>
<span class="pre">b*x</span> <span class="pre">+</span> <span class="pre">c))</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">sm.solve(sm.Poly(</span>
<span class="pre">sm.Matrix([1,2,3]).</span>
<span class="pre">reshape(3,</span> <span class="pre">1),</span> <span class="pre">x),</span>
<span class="pre">x)</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../../solvers/solvers.html#solvers"><span class="std std-ref">Solvers</span></a>.</p>
<p>For numerical
computation related
to polynomials and
roots refer to
<a class="reference external" href="http://docs.sympy.org/0.7.6/modules/mpmath/calculus/polynomials.html">mpmath/calculus.</a></p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Solve(A,</span> <span class="pre">x1,</span> <span class="pre">x2)</span></code></p>
<p>where A is an
augmented matrix that
represents the linear
equations and x1, x2
are the variables to
solve for.</p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">sm.linsolve(A,</span>
<span class="pre">(x1,</span> <span class="pre">x2))</span></code></p>
<p>where A is an
augmented matrix</p>
</td>
<td><p>For more information
refer to
:ref:`
solvers/solveset.
&lt;solveset&gt;`</p>
<p>For non linear solvers
refer to
<code class="docutils literal notranslate"><span class="pre">nonlinsolve</span></code> and
<code class="docutils literal notranslate"><span class="pre">nsolve</span></code> in
<a class="reference internal" href="../../solvers/solvers.html#solvers"><span class="std std-ref">solvers.</span></a></p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">RowMatrix</span> <span class="pre">=</span> <span class="pre">[1,</span> <span class="pre">2,</span>
<span class="pre">3,</span> <span class="pre">4]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">ColMatrix</span> <span class="pre">=</span> <span class="pre">[1;</span> <span class="pre">2;</span>
<span class="pre">3;</span> <span class="pre">4]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">MO</span> <span class="pre">=</span> <span class="pre">[a,</span> <span class="pre">b;</span> <span class="pre">c,</span> <span class="pre">0]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">MO[2,</span> <span class="pre">2]</span> <span class="pre">:=</span> <span class="pre">d</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A</span> <span class="pre">+</span> <span class="pre">B*C</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Cols(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Cols(A,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Rows(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Rows(A,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Det(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Element(A,</span> <span class="pre">2,</span> <span class="pre">3)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Inv(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Trace(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Transpose(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Diagmat(4,</span> <span class="pre">1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Eig(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Eig(A,</span> <span class="pre">EigVal,</span>
<span class="pre">EigVec)</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">row_matrix</span> <span class="pre">=</span>
<span class="pre">sm.Matrix([[1],[2],</span>
<span class="pre">[3],[4]])</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">col_matrix</span> <span class="pre">=</span>
<span class="pre">sm.Matrix([1,</span> <span class="pre">2,</span> <span class="pre">3,</span>
<span class="pre">4])</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">MO</span> <span class="pre">=</span> <span class="pre">sm.Matrix([[a,</span>
<span class="pre">b],</span> <span class="pre">[c,</span> <span class="pre">0]])</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">MO[1,</span> <span class="pre">1]</span> <span class="pre">=</span> <span class="pre">d</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A</span> <span class="pre">+</span> <span class="pre">B*C</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.cols</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.col(0)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.rows</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.row(0)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">M.det()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">M[2,</span> <span class="pre">3]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">M**-1</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">sm.trace(A)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.T</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">sm.diag(1,1,1,1)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A.eigenvals()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">eigval</span> <span class="pre">=</span>
<span class="pre">A.eigenvals()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">eigvec</span> <span class="pre">=</span>
<span class="pre">A.eigenvects()</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../../../tutorial/matrices.html#matrices"><span class="std std-ref">matrices.</span></a></p></td>
</tr>
</tbody>
</table>
</section>
<section id="physical-equivalents">
<h3>Physical Equivalents<a class="headerlink" href="#physical-equivalents" title="Permalink to this headline">¶</a></h3>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p><strong>Autolev</strong></p></th>
<th class="head"><p><strong>SymPy</strong></p></th>
<th class="head"><p><strong>Notes</strong></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Bodies</span> <span class="pre">A</span></code></p>
<p>Declares A, its
masscenter Ao, and
orthonormal vectors
A1&gt;, A2&gt; and A3&gt;
fixed in A.</p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">=sm.symbols(‘m’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Ao</span> <span class="pre">=</span>
<span class="pre">sm.symbols(‘Ao’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Af</span> <span class="pre">=</span>
<span class="pre">me.ReferenceFrame(‘Af’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">I</span> <span class="pre">=</span>
<span class="pre">me.outer(Af.x,Af.x)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">P</span> <span class="pre">=</span> <span class="pre">me.Point(‘P’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">A</span> <span class="pre">=me.RigidBody(‘A’,</span>
<span class="pre">Ao,</span> <span class="pre">Af,</span> <span class="pre">m,</span> <span class="pre">(I,</span> <span class="pre">P))</span></code></p>
<p>Af.x, Af.y and Af.z
are equivalent to
A1&gt;, A2&gt; and A3&gt;.</p>
</td>
<td><p>The 4th and 5th
arguments are for the
mass and inertia.
These are specified
after the declaration
in Autolev.</p>
<p>One can pass a dummy
for the parameters
and use setters
<code class="docutils literal notranslate"><span class="pre">A.mass</span> <span class="pre">=</span> <span class="pre">\_</span></code> and
<code class="docutils literal notranslate"><span class="pre">A.inertia</span> <span class="pre">=</span> <span class="pre">\_</span></code> to
set them later.</p>
<p>For more information
refer to
<a class="reference internal" href="masses.html#masses"><span class="std std-ref">mechanics/masses
.</span></a></p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Frames</span> <span class="pre">A</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">V1&gt;</span> <span class="pre">=</span>
<span class="pre">X1*A1&gt;</span> <span class="pre">+</span> <span class="pre">X2*A2&gt;</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">A</span> <span class="pre">=</span>
<span class="pre">me.ReferenceFrame(‘A’</span>
<span class="pre">)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">v1</span> <span class="pre">=</span>
<span class="pre">x1*A.x</span> <span class="pre">+</span> <span class="pre">x2*A.y</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../../../tutorial/matrices.html#matrices"><span class="std std-ref">physics/vectors.</span></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Newtonian</span> <span class="pre">N</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">N</span> <span class="pre">=</span>
<span class="pre">me.ReferenceFrame(‘N’</span>
<span class="pre">)</span></code></p></td>
<td><p>SymPy doesn’t specify
that a frame is
inertial during
declaration. Many
functions such as
<code class="docutils literal notranslate"><span class="pre">set_ang_vel()</span></code> take
the inertial
reference frame as a
parameter.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Particles</span> <span class="pre">C</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">=</span>
<span class="pre">sm.symbols(‘m’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Po</span> <span class="pre">=</span>
<span class="pre">me.Point(‘Po’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">C</span> <span class="pre">=</span> <span class="pre">me.Particle(‘C’,</span>
<span class="pre">Po,</span> <span class="pre">m)</span></code></p>
</td>
<td><p>The 2nd and 3rd
arguments are for the
point and mass. In
Autolev, these are
specified after the
declaration.</p>
<p>One can pass a dummy
and use setters
(<code class="docutils literal notranslate"><span class="pre">A.point</span> <span class="pre">=</span> <span class="pre">\_</span></code> and
<code class="docutils literal notranslate"><span class="pre">A.mass</span> <span class="pre">=</span> <span class="pre">\_</span></code>) to
set them later.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Points</span> <span class="pre">P,</span> <span class="pre">Q</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">P</span> <span class="pre">=</span> <span class="pre">me.Point(‘P’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Q</span> <span class="pre">=</span> <span class="pre">me.Point(‘Q’)</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Mass</span> <span class="pre">B=mB</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">mB</span> <span class="pre">=</span> <span class="pre">symbols(‘mB’)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">B.mass</span> <span class="pre">=</span> <span class="pre">mB</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Inertia</span> <span class="pre">B,</span> <span class="pre">I1,</span> <span class="pre">I2,</span>
<span class="pre">I3,</span> <span class="pre">I12,</span> <span class="pre">I23,</span> <span class="pre">I31</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">I</span> <span class="pre">=</span> <span class="pre">me.inertia(Bf,</span>
<span class="pre">i1,</span> <span class="pre">i2,</span> <span class="pre">i3,</span> <span class="pre">i12,</span> <span class="pre">i23,</span>
<span class="pre">i31)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">B.inertia</span> <span class="pre">=</span> <span class="pre">(I,</span> <span class="pre">P)</span></code>
where B is a
rigidbody, Bf is the
related frame and P is
the center of mass of
B.</p>
<p>Inertia dyadics can
also be formed using
vector outer products.</p>
<p><code class="docutils literal notranslate"><span class="pre">I</span> <span class="pre">=</span>
<span class="pre">me.outer(N.x,</span> <span class="pre">N.x)</span></code></p>
</td>
<td><p>For more information
refer to the
<a class="reference internal" href="api/part_bod.html#part-bod"><span class="std std-ref">mechanics api.</span></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">vec&gt;</span> <span class="pre">=</span> <span class="pre">P_O_Q&gt;/L</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">vec&gt;</span> <span class="pre">=</span>
<span class="pre">u1*N1&gt;</span> <span class="pre">+</span> <span class="pre">u2*N2&gt;</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Cross(a&gt;,</span> <span class="pre">b&gt;)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Dot(a&gt;,</span> <span class="pre">b&gt;)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Mag(v&gt;)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Unitvec(v&gt;)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">DYAD&gt;&gt;</span> <span class="pre">=</span> <span class="pre">3*A1&gt;*A1&gt;</span> <span class="pre">+</span>
<span class="pre">A2&gt;*A2&gt;</span> <span class="pre">+</span> <span class="pre">2*A3&gt;*A3&gt;</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">vec</span>&#160; <span class="pre">=</span>
<span class="pre">(Qo.pos_from(O))/L</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">vec</span> <span class="pre">=</span>
<span class="pre">u1*N.x</span> <span class="pre">+</span> <span class="pre">u2*N.y</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">cross(a,</span> <span class="pre">b)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">dot(a,</span> <span class="pre">b)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">v.magnitude()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">v.normalize()</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">dyad</span> <span class="pre">=</span>
<span class="pre">3*me.outer(a.x</span>
<span class="pre">,a.x)</span> <span class="pre">+</span> <span class="pre">me.outer(a.y,</span>
<span class="pre">a.y)</span> <span class="pre">+</span> <span class="pre">2*me.outer(a.z</span>
<span class="pre">,a.z)</span></code></p>
</td>
<td><p>For more information
refer to
<a class="reference internal" href="../vector/index.html#physics-vector"><span class="std std-ref">physics/vectors.</span></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">P_O_Q&gt;</span> <span class="pre">=</span> <span class="pre">LA*A1&gt;</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">P_P_Q&gt;</span> <span class="pre">=</span> <span class="pre">LA*A1&gt;</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">Q.point</span> <span class="pre">=</span>
<span class="pre">O.locatenew(‘Qo’,</span>
<span class="pre">LA*A.x)</span></code></p>
<p>where A is a
reference frame.</p>
<p><code class="docutils literal notranslate"><span class="pre">Q.point</span> <span class="pre">=</span>
<span class="pre">P.point.locatenew(‘Qo</span>
<span class="pre">’,</span>
<span class="pre">LA*A.x)</span></code></p>
</td>
<td><p>For more information
refer to the
<a class="reference internal" href="../vector/api/kinematics.html#kinematics"><span class="std std-ref">kinematics api.</span></a></p>
<p>All these vector and
kinematic functions
are to be used on
<code class="docutils literal notranslate"><span class="pre">Point</span></code> objects and
not <code class="docutils literal notranslate"><span class="pre">Particle</span></code>
objects so <code class="docutils literal notranslate"><span class="pre">.point</span></code>
must be used for
particles.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">V_O_N&gt;</span> <span class="pre">=</span> <span class="pre">u3*N.1&gt;</span> <span class="pre">+</span>
<span class="pre">u4*N.2&gt;</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Partials(V_O_N&gt;,</span>
<span class="pre">u3)</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">O.set_vel(N,</span> <span class="pre">u1*N.x</span>
<span class="pre">+</span> <span class="pre">u2*N.y)</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">O.partial_velocity(N</span>
<span class="pre">,</span> <span class="pre">u3)</span></code></p>
</td>
<td><p>The getter would be
<code class="docutils literal notranslate"><span class="pre">O.vel(N)</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">A_O_N&gt;</span> <span class="pre">=</span> <span class="pre">0&gt;</span></code></p>
<p>Acceleration of point
O in reference frame
N.</p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">O.set_acc(N,</span> <span class="pre">0)</span></code></p></td>
<td><p>The getter would be
<code class="docutils literal notranslate"><span class="pre">O.acc(N)</span></code>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">W_B_N&gt;</span> <span class="pre">=</span> <span class="pre">qB’*B3&gt;</span></code></p>
<p>Angular velocity of
body B in reference
frame F.</p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.set_ang_vel(N,</span>
<span class="pre">qBd*Bf.z)</span></code></p>
<p>where Bf is the frame
associated with the
body B.</p>
</td>
<td><p>The getter would be
<code class="docutils literal notranslate"><span class="pre">B.ang_vel_in(N)</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">ALF_B_N&gt;</span> <span class="pre">=Dt(W_B_N&gt;,</span>
<span class="pre">N)</span></code></p>
<p>Angular acceleration
of body B in
reference frame N.</p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.set_ang_acc(N,</span>
<span class="pre">diff(B.ang_vel_in(N)</span>
<span class="pre">)</span></code></p></td>
<td><p>The getter would be
<code class="docutils literal notranslate"><span class="pre">B.ang_acc_in(N)</span></code>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Force_O&gt;</span> <span class="pre">=</span> <span class="pre">F1*N1&gt;</span> <span class="pre">+</span>
<span class="pre">F2*N2&gt;</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">Torque_A&gt;</span> <span class="pre">=</span>
<span class="pre">-c*qA’*A3&gt;</span></code></p>
</td>
<td><p>In SymPy one should
have a list which
contains all the
forces and torques.</p>
<p><code class="docutils literal notranslate"><span class="pre">fL.append((O,</span> <span class="pre">f1*N.x</span>
<span class="pre">+</span> <span class="pre">f2*N.y))</span></code></p>
<p>where fL is the force
list.</p>
<p><code class="docutils literal notranslate"><span class="pre">fl.append((A,</span>
<span class="pre">-c*qAd*A.z))</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">A_B</span> <span class="pre">=</span> <span class="pre">M</span></code>
where M is a matrix
and A, B are frames.</p>
<p><code class="docutils literal notranslate"><span class="pre">D</span> <span class="pre">=</span> <span class="pre">A_B*2</span> <span class="pre">+</span> <span class="pre">1</span></code></p>
</td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.orient(A,</span> <span class="pre">'DCM',</span>
<span class="pre">M)</span></code> where M is a
SymPy Matrix.</p>
<p><code class="docutils literal notranslate"><span class="pre">D</span> <span class="pre">=</span> <span class="pre">A.dcm(B)*2</span> <span class="pre">+</span> <span class="pre">1</span></code></p>
</td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CM(B)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.masscenter</span></code></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Mass(A,B,C)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">A.mass</span> <span class="pre">+</span> <span class="pre">B.mass</span> <span class="pre">+</span>
<span class="pre">C.mass</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">V1pt(A,B,P,Q)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">Q.v1pt_theory(P,</span> <span class="pre">A,</span>
<span class="pre">B)</span></code></p></td>
<td><p>P and Q are assumed to
be <code class="docutils literal notranslate"><span class="pre">Point</span></code> objects
here. Remember to use
<code class="docutils literal notranslate"><span class="pre">.point</span></code> for
particles.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">V2pts(A,B,P,Q)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">Q.v2pt_theory(P,</span> <span class="pre">A,</span>
<span class="pre">B)</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">A1pt(A,B,P,Q)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">Q.a1pt_theory(P,</span> <span class="pre">A,</span>
<span class="pre">B)</span></code></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">A2pts(A,B,P,Q)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">Q.a2pt_theory(P,</span> <span class="pre">A,</span>
<span class="pre">B)</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Angvel(A,B)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.ang_vel_in(A)</span></code></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Simprot(A,</span> <span class="pre">B,</span> <span class="pre">1,</span>
<span class="pre">qA)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">B.orient(A,</span> <span class="pre">‘Axis’,</span>
<span class="pre">qA,</span> <span class="pre">A.x)</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Gravity(G*N1&gt;)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">fL.extend(gravity(</span>
<span class="pre">g*N.x,</span> <span class="pre">P1,</span> <span class="pre">P2,</span> <span class="pre">...))</span></code></p></td>
<td><p>In SymPy we must use a
forceList (here fL)
which contains tuples
of the form <code class="docutils literal notranslate"><span class="pre">(point,</span>
<span class="pre">force_vector)</span></code>. This
is passed to the
<code class="docutils literal notranslate"><span class="pre">kanes_equations()</span></code>
method of the
KanesMethod object.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CM(O,P1,R)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">me.functions.</span>
<span class="pre">center_of_mass(o,</span> <span class="pre">p1,</span>
<span class="pre">r)</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Force(P/Q,</span> <span class="pre">v&gt;)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">fL.append((P,</span> <span class="pre">-1*v),</span>
<span class="pre">(Q,</span> <span class="pre">v))</span></code></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Torque(A/B,</span> <span class="pre">v&gt;)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">fL.append((A,</span> <span class="pre">-1*v),</span>
<span class="pre">(B,</span> <span class="pre">v))</span></code></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Kindiffs(A,</span> <span class="pre">B</span> <span class="pre">...)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">KM.kindiffdict()</span></code></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Momentum(option)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">linear_momentum(N,</span>
<span class="pre">B1,</span> <span class="pre">B2</span> <span class="pre">...)</span></code></p>
<p>reference frame
followed by one or
more bodies</p>
<p><code class="docutils literal notranslate"><span class="pre">angular_momentum(O,</span>
<span class="pre">N,</span> <span class="pre">B1,</span> <span class="pre">B2</span> <span class="pre">...)</span></code></p>
<p>point, reference
frame followed by one
or more bodies</p>
</td>
<td></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">KE()</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">kinetic_energy(N,</span>
<span class="pre">B1,</span> <span class="pre">B2</span> <span class="pre">...)</span></code></p>
<p>reference frame
followed by one or
more bodies</p>
</td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Constrain(...)</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">velocity_constraints</span>
<span class="pre">=</span> <span class="pre">[...]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">u_dependent</span> <span class="pre">=</span>
<span class="pre">[...]</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">u_auxiliary</span> <span class="pre">=</span>
<span class="pre">[...]</span></code></p>
<p>These lists are
passed to the
KanesMethod object.</p>
</td>
<td><p>For more details
refer to
<a class="reference internal" href="kane.html#kane-method"><span class="std std-ref">mechanics/kane</span></a> and
the <a class="reference internal" href="api/kane_lagrange.html#kane-lagrange"><span class="std std-ref">kane api.</span></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Fr()</span></code>
<code class="docutils literal notranslate"><span class="pre">FrStar()</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">KM</span> <span class="pre">=</span> <span class="pre">KanesMethod(f,</span>
<span class="pre">q_ind,</span> <span class="pre">u_ind,</span> <span class="pre">kd_eqs,</span>
<span class="pre">q_dependent,</span> <span class="pre">configura</span>
<span class="pre">tion_constraints,</span> <span class="pre">u_de</span>
<span class="pre">pendent,</span> <span class="pre">velocity_cons</span>
<span class="pre">traints,</span> <span class="pre">acceleration_</span>
<span class="pre">constraints,</span> <span class="pre">u_auxilia</span>
<span class="pre">ry)</span></code></p>
<p>The KanesMethod
object takes a
reference frame
followed by multiple
lists as arguments.</p>
<p><code class="docutils literal notranslate"><span class="pre">(fr,</span> <span class="pre">frstar)</span> <span class="pre">=</span>
<span class="pre">KM.kanes_equations(fL,</span>
<span class="pre">bL)</span></code> where fL and bL
are lists of forces
and bodies
respectively.</p>
</td>
<td><p>For more details
refer to
<a class="reference internal" href="kane.html#kane-method"><span class="std std-ref">mechanics/kane</span></a> and
the <a class="reference internal" href="api/kane_lagrange.html#kane-lagrange"><span class="std std-ref">kane api.</span></a></p></td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="numerical-evaluation-and-visualization">
<h2>Numerical Evaluation and Visualization<a class="headerlink" href="#numerical-evaluation-and-visualization" title="Permalink to this headline">¶</a></h2>
<p>Autolev’s CODE Option() command allows one to generate Matlab, C, or
Fortran code for numerical evaluation and visualization. Option can be
Dynamics, ODE, Nonlinear or Algebraic.</p>
<p>Numerical evaluation for dynamics can be achieved using PyDy. One can
pass in the KanesMethod object to the System class along with the values
for the constants, specifieds, initial conditions and time steps. The
equations of motion can then be integrated. The plotting is achieved
using matlplotlib. Here is an example from the <a class="reference external" href="https://www.pydy.org/documentation.html">PyDy Documentation</a>
on how it is done:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">array</span><span class="p">,</span> <span class="n">linspace</span><span class="p">,</span> <span class="n">sin</span>
<span class="kn">from</span> <span class="nn">pydy.system</span> <span class="kn">import</span> <span class="n">System</span>

<span class="n">sys</span> <span class="o">=</span> <span class="n">System</span><span class="p">(</span><span class="n">kane</span><span class="p">,</span>
             <span class="n">constants</span> <span class="o">=</span> <span class="p">{</span><span class="n">mass</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">stiffness</span><span class="p">:</span> <span class="mf">1.0</span><span class="p">,</span>
                          <span class="n">damping</span><span class="p">:</span> <span class="mf">0.2</span><span class="p">,</span> <span class="n">gravity</span><span class="p">:</span> <span class="mf">9.8</span><span class="p">},</span>
             <span class="n">specifieds</span> <span class="o">=</span> <span class="p">{</span><span class="n">force</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">:</span> <span class="n">sin</span><span class="p">(</span><span class="n">t</span><span class="p">)},</span>
             <span class="n">initial_conditions</span> <span class="o">=</span> <span class="p">{</span><span class="n">position</span><span class="p">:</span> <span class="mf">0.1</span><span class="p">,</span> <span class="n">speed</span><span class="p">:</span><span class="o">-</span><span class="mf">1.0</span><span class="p">},</span>
             <span class="n">times</span> <span class="o">=</span> <span class="n">linspace</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">10.0</span><span class="p">,</span> <span class="mi">1000</span><span class="p">))</span>

<span class="n">y</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">integrate</span><span class="p">()</span>

<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">times</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">((</span><span class="nb">str</span><span class="p">(</span><span class="n">position</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">speed</span><span class="p">)))</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>For information on all the things PyDy can accomplish refer to the
<a class="reference external" href="https://www.pydy.org/documentation.html">PyDy Documentation</a>.</p>
<p>The tools in the PyDy workflow are :</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference external" href="https://sympy.org/">SymPy</a>: SymPy is a Python library for</dt><dd><p>symbolic computation. It provides computer algebra capabilities
either as a standalone application, as a library to other
applications, or live on the web as SymPy Live or SymPy Gamma.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.numpy.org/">NumPy</a>: NumPy is a library for the</dt><dd><p>Python programming language, adding support for large,
multi-dimensional arrays and matrices, along with a large
collection of high-level mathematical functions to operate on
these arrays.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://www.scipy.org/">SciPy</a>: SciPy is an open source</dt><dd><p>Python library used for scientific computing and technical
computing. SciPy contains modules for optimization, linear
algebra, integration, interpolation, special functions, FFT,
signal and image processing, ODE solvers and other tasks common
in science and engineering.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://ipython.org/">IPython</a>: IPython is a command shell</dt><dd><p>for interactive computing in multiple programming languages,
originally developed for the Python programming language, that
offers introspection, rich media, shell syntax, tab completion,
and history.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://aesara.readthedocs.io/en/latest/">Aesara</a>: Aesara is</dt><dd><p>a numerical computation library for Python. In Aesara,
computations are expressed using a NumPy-esque syntax and
compiled to run efficiently on either CPU or GPU architectures.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="http://cython.org/">Cython</a>: Cython is a superset of the</dt><dd><p>Python programming language, designed to give C-like performance
with code that is mostly written in Python. Cython is a compiled
language that generates CPython extension modules.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference external" href="https://matplotlib.org/">matplotlib</a>: matplotlib is a</dt><dd><p>plotting library for the Python programming language and its
numerical mathematics extension NumPy.</p>
</dd>
</dl>
</li>
</ul>
<p>One will be able to write code equivalent to the Matlab, C or Fortran
code generated by Autolev using these scientific computing tools. It is
recommended to go over these modules to gain an understanding of
scientific computing with Python.</p>
</section>
<section id="links">
<h2>Links<a class="headerlink" href="#links" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="../../../tutorial/index.html#tutorial"><span class="std std-ref">SymPy Tutorial</span></a></p>
<p><a class="reference internal" href="../../../index.html#documentation"><span class="std std-ref">SymPy Documentation</span></a></p>
<p><a class="reference internal" href="../vector/index.html#physics-vector"><span class="std std-ref">SymPy Physics Vector
Documentation</span></a></p>
<p><a class="reference internal" href="index.html#classical-mechanics"><span class="std std-ref">SymPy Mechanics
Documentation</span></a></p>
<p><a class="reference external" href="https://www.pydy.org/documentation.html">PyDy Documentation</a></p>
<p><a class="reference external" href="https://www.youtube.com/watch?v=mdo2NYtA-xY">MultiBody Dynamics with Python</a></p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../../index.html">
              <img class="logo" src="../../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">SymPy Mechanics for Autolev Users</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#some-key-differences">Some Key Differences</a></li>
<li><a class="reference internal" href="#rough-autolev-sympy-equivalents">Rough Autolev-SymPy Equivalents</a><ul>
<li><a class="reference internal" href="#mathematical-equivalents">Mathematical Equivalents</a></li>
<li><a class="reference internal" href="#physical-equivalents">Physical Equivalents</a></li>
</ul>
</li>
<li><a class="reference internal" href="#numerical-evaluation-and-visualization">Numerical Evaluation and Visualization</a></li>
<li><a class="reference internal" href="#links">Links</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="autolev_parser.html"
                        title="previous chapter">Autolev Parser</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="api/part_bod.html"
                        title="next chapter">Masses, Inertias &amp; Particles, RigidBodys (Docstrings)</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/modules/physics/mechanics/sympy_mechanics_for_autolev_users.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api/part_bod.html" title="Masses, Inertias &amp; Particles, RigidBodys (Docstrings)"
             >next</a> |</li>
        <li class="right" >
          <a href="autolev_parser.html" title="Autolev Parser"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" >Classical Mechanics</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">SymPy Mechanics for Autolev Users</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/physics/mechanics/sympy_mechanics_for_autolev_users.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:39 GMT -->
</html>